package com.design.mode.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @ClassName ParamAspect
 * @Description TODO
 * @Author xiongchao
 * @Date 2020/10/10 14:42
 **/
@Aspect
@Component
public class ParamAspect {

    @Pointcut("execution(* com.design.mode.aop.BuyWithParam.buy(double)) && args(price) && bean(girls)")
    public void point(double price){

    }

    @Around("point(price)")
    public String gift(ProceedingJoinPoint pj,double price ){

        try {
            pj.proceed();
            if(price > 68){
                System.out.println("女孩买的衣服超过了68,送一双娃子");
                return "衣服和娃子";
            }
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return "衣服";
    }
}
